//
//  ProgressView.swift
//  WB
//
//  Created by leador on 17/6/9.
//  Copyright © 2017年 袁满. All rights reserved.
//

import UIKit

class ProgressView: UIView {

    var progress : CGFloat = 0 {
        
        didSet {
            setNeedsDisplay()
        }
        
    }

    override func draw(_ rect: CGRect) {
        super.draw(rect)
        
        let center = CGPoint(x: rect.width*0.5, y: rect.height*0.5)
        let radius = rect.width*0.5 - 3
        let startAngle = CGFloat(-M_PI_2)
        let endAngle = CGFloat(2*M_PI)*progress + startAngle
        
        let path = UIBezierPath(arcCenter: center, radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise: true)
        
        path.addLine(to: center)
        path.close()

        UIColor.red.setFill()
        
        path.stroke()
        
    }


}
